Avoid an out-of-bounds access
authorMatthias Clasen <mclasen@redhat.com>
Fri, 26 Feb 2016 20:50:31 +0000 (15:50 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 26 Feb 2016 20:52:19 +0000 (15:52 -0500)
When the offset gets smaller than min_offset, we can't
access the array at that position.

gtk/gtktextiter.c

index dc3891a1b4be89ab928122eb22c2ee2d6760933e..3e2e5f530092b75ae89f082f6d7b8ca193a772a3 100644 (file)
@@ -3073,9 +3073,12 @@ inside_sentence_func (const PangoLogAttr *attrs,
                       gint                len)
 {
   /* Find next sentence start or end */
-  while (offset >= min_offset &&
-         !(attrs[offset].is_sentence_start || attrs[offset].is_sentence_end))
-    --offset;
+  while (!(attrs[offset].is_sentence_start || attrs[offset].is_sentence_end))
+    {
+      --offset;
+      if (offset < min_offset)
+        return FALSE;
+    }
 
   return attrs[offset].is_sentence_start;
 }